package org.fu.crowd.mvc.controller;

import org.fu.crowd.entity.Auth;
import org.fu.crowd.entity.Common;
import org.fu.crowd.service.api.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class AuthController {
    @Autowired
    private AuthService authService;


    @ResponseBody
    @RequestMapping("/assign/getAllAuth")
    public Common<List<Auth>> getAllAuth(){
        List<Auth> allAuth = authService.getAllAuth();
        return Common.successWithoutData(allAuth);
    }




    @ResponseBody
    @RequestMapping("/assign/getAssigned")
    public Common<List<Integer>> getAssigned(@RequestParam("roleId")Integer roleId){
        List<Integer> list = authService.getAssigned(roleId);
        return Common.successWithoutData(list);
    }




    @ResponseBody
    @RequestMapping("/role/saveAuth")
    public Common<List<Integer>> saveAuth(@RequestBody Map<String,List<Integer>> listMap){
        authService.saveAuth(listMap);
        return Common.successWithoutData();
    }


}
